package com.yitongmao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yitongmao.yitmfruit.R;

/*
* 作者：梁伟航 on 2017/7/12 11:45
* 类的用途：
*/
public class MyAdapterGridView extends BaseAdapter {
    String[] arrayName = new String[]{"我的关注", "修改密码", "收货信息", "关于我们", "联系我们", "用户设置"};
    int[] array = new int[]{R.drawable.wodeguanzhu,R.drawable.xiugaimima, R.drawable.shouhuoxinxi,R.drawable.guanyuwomen, R.drawable.lianxiwomen,R.drawable.yonghushezhi};
    private Context context;

    public MyAdapterGridView(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return arrayName.length;
    }

    @Override
    public Object getItem(int position) {
        return arrayName[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.mygridviewitem, null);
            viewHolder.mMyGridViewTextViewTitle = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewTitle);
            viewHolder.mMyGridViewTextViewBody = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewBody);
            viewHolder.mMyGridViewImage = (ImageView) convertView.findViewById(R.id.mMyGridViewImage);
            convertView.setTag(viewHolder);//绑定ViewHolder对象
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mMyGridViewTextViewTitle.setText(arrayName[position]);
       // viewHolder.mMyGridViewTextViewBody.setText(array[position]);
        viewHolder.mMyGridViewImage.setImageResource(array[position]);
        return convertView;
    }
    class ViewHolder {
        public TextView mMyGridViewTextViewTitle;
        public TextView mMyGridViewTextViewBody;
        public ImageView mMyGridViewImage;
    }

}
